--Overrides so various e2 functions dupe properly

if SERVER then
	timer.Simple( 10, function()
	-----
	if not MakeSpherical then return end
	function MakeSpherical.ApplySphericalCollisionsE2( ent, enabled, radius )
		
		local phys = ent:GetPhysicsObject()
		local mass = phys:GetMass()
		local ismove = phys:IsMoveable()
		local issleep = phys:IsAsleep()
		local radius = math.Clamp( radius, 1, 200 )
		
		--	Dupe Compatibilty
		if not ent.noradius then
	
			local OBB = ent:OBBMaxs() - ent:OBBMins()
			ent.noradius = math.max( OBB.x, OBB.y, OBB.z) / 2 
		
		end
	
		ent.obbcenter = ent.obbcenter or ent:OBBCenter()
		local offsetvec = Vector( 0, 0, 0 )
		local data = 
		{
		// I store the obbcenter and "obb radius" because they are altered when SetCollisionBounds is used
		// This allows the spherical collisions to be reset even after duping
		obbcenter 		= ent.obbcenter,
		noradius 		= ent.noradius,
		radius 			= ent.noradius,
		mass 			= ent:GetPhysicsObject():GetMass(),
		enabled 		= true,
		isrenderoffset 	= 0,
		renderoffset 	= true and -ent.obbcenter or offsetvec
		}
		--
		
		if enabled then
		
			ent:PhysicsInitSphere( radius, phys:GetMaterial() )
			ent:SetCollisionBounds( Vector( -radius, -radius, -radius ) , Vector( radius, radius, radius ) )
		
		else
		
			ent:PhysicsInit( SOLID_VPHYSICS )
			ent:SetMoveType( MOVETYPE_VPHYSICS )
			ent:SetSolid( SOLID_VPHYSICS )
		
		end
		
		-- New physobject after applying spherical collisions
		local phys = ent:GetPhysicsObject()
		phys:SetMass( mass )
		phys:EnableMotion( ismove )
		if not issleep then phys:Wake() end
		
		--	Dupe Compatibilty
		data.radius = radius
		ent.noradius = data.noradius
		duplicator.StoreEntityModifier( ent, "MakeSphericalCollisions", data )
		--
		
	end
	
	-----
	end )
end